'use strict';
let Response = require('../../../model/Response');
let RestifyProxy = require('../../../util/RestifyProxy');
let CustomPageBean = require('../../../model/CustomPageBean');
let terminalReportService = require('../../../service/Report/terminalReportService');
let logger = require('../../../util/LoggerUtil').logger('terminalReportService.js');

/**
 * 终端报表页面
 */

module.exports.terminalReportPage = function () {
    let response = new Response();
    response.render('back/report/terminal-report/terminal-report');
    this.resolve(response);
};
/**
 * 终端报表列表
 */
module.exports.terminal_report_List = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await terminalReportService.getTerminalList(this, params);
        let pageBean = new CustomPageBean(result);
        response.send(pageBean);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 终端报表切换图表页面
 */

module.exports.changeCharPage = function () {
    let response = new Response();
    response.render('back/report/terminal-report/terminal-char');
    this.resolve(response);
};
/**
 * 终端报表Excel导出
 */
module.exports.terminalReportExport = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await terminalReportService.getTerminalReportExport(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};
/**
 * 终端图表数据
 */
module.exports.getChar = async function () {
    let req = this.req;
    let params = req.body;
    let response = new Response();
    try {
        let result = await terminalReportService.getChar(this, params);
        response.send(result);
    } catch (error) {
        logger.error(error);
    }
    this.resolve(response);
};

